package website.seamonster.ethegg.dataobject;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;

/**
 * Created by 罗海量
 * 2018-08-21 10:06
 */
@Entity
@Table(name = "sys_msg")
@Slf4j
@Data
@DynamicInsert
@DynamicUpdate
public class Msg {

    private String id;
    private int msgType;
    private String userId;
    private BigDecimal income;
    private BigDecimal someVal;
    private Boolean readStatus;
    private Timestamp createTime;
    private long blockNum;

    @Id
    @Column(name = "ID")
    @GenericGenerator(name = "user-uuid", strategy = "uuid")
    @GeneratedValue(generator = "user-uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "MSG_TYPE")
    public int getMsgType() {
        return msgType;
    }

    public void setMsgType(int msgType) {
        this.msgType = msgType;
    }

    @Basic
    @Column(name = "USER_ID")
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    @Basic
    @Column(name = "INCOME")
    public BigDecimal getIncome() {
        return income;
    }

    public void setIncome(BigDecimal income) {
        this.income = income;
    }

    @Basic
    @Column(name = "SOME_VAL")
    public BigDecimal getSomeVal() {
        return someVal;
    }

    public void setSomeVal(BigDecimal someVal) {
        this.someVal = someVal;
    }

    @Basic
    @Column(name = "READ_STATUS")
    public Boolean getReadStatus() {
        return readStatus;
    }

    public void setReadStatus(Boolean readStatus) {
        this.readStatus = readStatus;
    }

    @Basic
    @Column(name = "CREATE_TIME")
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "BLOCK_NUM")
    public long getBlockNum() {
        return blockNum;
    }

    public void setBlockNum(long blockNum) {
        this.blockNum = blockNum;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Msg msg = (Msg) o;

        if (msgType != msg.msgType) return false;
        if (blockNum != msg.blockNum) return false;
        if (id != null ? !id.equals(msg.id) : msg.id != null) return false;
        if (userId != null ? !userId.equals(msg.userId) : msg.userId != null) return false;
        if (income != null ? !income.equals(msg.income) : msg.income != null) return false;
        if (readStatus != null ? !readStatus.equals(msg.readStatus) : msg.readStatus != null) return false;
        if (createTime != null ? !createTime.equals(msg.createTime) : msg.createTime != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + msgType;
        result = 31 * result + (userId != null ? userId.hashCode() : 0);
        result = 31 * result + (income != null ? income.hashCode() : 0);
        result = 31 * result + (readStatus != null ? readStatus.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (int) (blockNum ^ (blockNum >>> 32));
        return result;
    }
}
